﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="NuevaFactura.aspx.cs" Inherits="SistemaFacturacionWeb.Formulario_web14" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
        .auto-style2 {
            width: 87px;
        }
        .auto-style3 {
            width: 122px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
   
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
     <h1>Nueva Factura</h1>
     <p>&nbsp;</p>

    <script type="text/javascript">
        $(function () {
            $(".myDatePicker").datepicker();
        });
                </script>

     <table class="auto-style1">
         <tr>
             <td class="auto-style2" style="text-align: right">Fecha: *</td>
             <td colspan="2">
                 <asp:TextBox ID="TxtFecha" runat="server" CssClass="myDatePicker" Enabled="False" ReadOnly="True"></asp:TextBox>
             </td>
         </tr>
         <tr>
             <td class="auto-style2" style="text-align: right">Cliente: *</td>
             <td colspan="2">
                 <asp:DropDownList ID="DropDownListCliente" runat="server" Height="18px" Width="350px" DataSourceID="SqlDataSourceClientes" DataTextField="Apellidos" DataValueField="IDCliente">
                 </asp:DropDownList>
                 <asp:SqlDataSource ID="SqlDataSourceClientes" runat="server" ConnectionString="<%$ ConnectionStrings:FacturacionConnectionString1 %>" SelectCommand="SELECT IDCliente, Apellidos FROM Cliente UNION SELECT '0' AS Expr1, '[Seleccione un cliente]' AS Expr2 ORDER BY Apellidos"></asp:SqlDataSource>
             </td>
         </tr>
         <tr>
             <td class="auto-style2" style="text-align: right">Producto: *</td>
             <td colspan="2">
                 <asp:DropDownList ID="DropDownListProducto" runat="server" Width="350px" DataSourceID="SqlDataSourceProductos" DataTextField="Descripcion" DataValueField="IDProducto">
                 </asp:DropDownList>
                 <asp:SqlDataSource ID="SqlDataSourceProductos" runat="server" ConnectionString="<%$ ConnectionStrings:FacturacionConnectionString1 %>" SelectCommand="SELECT IDProducto, Descripcion FROM Producto UNION SELECT '' AS Expr1, '[Seleccione un producto]' AS Expr2 ORDER BY Descripcion"></asp:SqlDataSource>
             </td>
         </tr>
         <tr>
             <td class="auto-style2" style="text-align: right">Cantidad: *</td>
             <td>
                 <asp:TextBox ID="TxtCantidad" runat="server"></asp:TextBox>
             </td>
             <td>
                 &nbsp;</td>
         </tr>
         <tr>
             <td class="auto-style2">&nbsp;</td>
             <td>
                 <asp:Button ID="BtnAgregar" runat="server" Text="Agregar" OnClick="BtnAgregar_Click" />
                 <asp:Button ID="BtnLimpiar" runat="server" Text="Limpiar" />
                 <asp:Button ID="BtnGuardar" runat="server" Text="Guardar factura" OnClick="BtnGuardar_Click" />
                <asp:Label ID="LabelMensajeAltaFactura" runat="server" Font-Bold="True" Font-Names="Cambria" Font-Size="Large" ForeColor="Maroon"></asp:Label>
             </td>
             <td>
                 &nbsp;</td>
         </tr>
     </table>
     <asp:GridView ID="GridViewFacturaTmp" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="IDLinea" DataSourceID="SqlDataSourceDetalleFactura" EmptyDataText="No hay registros de datos para mostrar." ForeColor="#333333" GridLines="None">
         <AlternatingRowStyle BackColor="White" />
         <Columns>
             <asp:CommandField HeaderText="Comandos" ShowDeleteButton="True" ShowEditButton="True" />
             <asp:BoundField DataField="IDLinea" HeaderText="ID Linea" ReadOnly="True" SortExpression="IDLinea" />
             <asp:BoundField DataField="IDProducto" HeaderText="ID Producto" SortExpression="IDProducto" />
             <asp:BoundField DataField="Descripcion" HeaderText="Descripción" SortExpression="Descripcion" />
             <asp:BoundField DataField="Cantidad" HeaderText="Cantidad" SortExpression="Cantidad">
             <ItemStyle HorizontalAlign="Right" />
             </asp:BoundField>
             <asp:BoundField DataField="Precio" HeaderText="Precio" SortExpression="Precio">
             <ItemStyle HorizontalAlign="Right" />
             </asp:BoundField>
         </Columns>
         <EditRowStyle BackColor="#2461BF" />
         <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
         <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
         <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
         <RowStyle BackColor="#EFF3FB" />
         <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
         <SortedAscendingCellStyle BackColor="#F5F7FB" />
         <SortedAscendingHeaderStyle BackColor="#6D95E1" />
         <SortedDescendingCellStyle BackColor="#E9EBEF" />
         <SortedDescendingHeaderStyle BackColor="#4870BE" />
     </asp:GridView>
     <asp:SqlDataSource ID="SqlDataSourceDetalleFactura" runat="server" ConnectionString="<%$ ConnectionStrings:FacturacionConnectionString1 %>" DeleteCommand="DELETE FROM [DetalleFacturaTmp] WHERE [IDLinea] = @IDLinea" InsertCommand="INSERT INTO [DetalleFacturaTmp] ([IDProducto], [Descripcion], [Precio], [Cantidad]) VALUES (@IDProducto, @Descripcion, @Precio, @Cantidad)" ProviderName="<%$ ConnectionStrings:FacturacionConnectionString1.ProviderName %>" SelectCommand="SELECT [IDLinea], [IDProducto], [Descripcion], [Precio], [Cantidad] FROM [DetalleFacturaTmp]" UpdateCommand="UPDATE [DetalleFacturaTmp] SET [IDProducto] = @IDProducto, [Descripcion] = @Descripcion, [Precio] = @Precio, [Cantidad] = @Cantidad WHERE [IDLinea] = @IDLinea">
         <DeleteParameters>
             <asp:Parameter Name="IDLinea" Type="Int32" />
         </DeleteParameters>
         <InsertParameters>
             <asp:Parameter Name="IDProducto" Type="Int32" />
             <asp:Parameter Name="Descripcion" Type="String" />
             <asp:Parameter Name="Precio" Type="Decimal" />
             <asp:Parameter Name="Cantidad" Type="Int32" />
         </InsertParameters>
         <UpdateParameters>
             <asp:Parameter Name="IDProducto" Type="Int32" />
             <asp:Parameter Name="Descripcion" Type="String" />
             <asp:Parameter Name="Precio" Type="Decimal" />
             <asp:Parameter Name="Cantidad" Type="Int32" />
             <asp:Parameter Name="IDLinea" Type="Int32" />
         </UpdateParameters>
     </asp:SqlDataSource>
     <table class="auto-style1">
         <tr>
             <td class="auto-style3">Cantidad total items: </td>
             <td>
                 <asp:TextBox ID="TxtCantidadItems" runat="server">0</asp:TextBox>
             </td>
         </tr>
         <tr>
             <td class="auto-style3">Total a pagar:</td>
             <td>
                 <asp:TextBox ID="TxtTotalAPagar" runat="server">0</asp:TextBox>
             </td>
         </tr>
     </table>
     <br />
    <br />
    
</asp:Content>
